JavaScript Array []
Example
// Create an Array
const cars = ["Saab", "Volvo", "BMW"];
Try it Yourself »
More Examples Below !
Description
The [ ] constructor creates a new array object.
Syntax
[iterable]
Parameters
| Parameter | Description |
| iterable | Required. An iterable object with values. |
Return Value
| Type | Description |
| Array | A new Array object. |
Array Tutorials:
More Examples
Example
Create an empty array and add values:
// Create an Array
const cars = [];
// Add Values to the Set
cars.push("Saab");
cars.push("Volvo");
cars.push("BMW");
Try it Yourself »
Example
Create an array with the new Array() method:
// Create an Array
const cars = new Array(["Saab", "Volvo", "BMW"]);
Try it Yourself »
Browser Support
the [] array constructor is an ECMAScript1 (JavaScript 1997) feature.
It is supported in all browsers:
| Chrome | Edge | Firefox | Safari | Opera |